home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 213 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.8 KB

  1. From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de>
  2. Message-ID: <9602011318.AA07436@lts.sel.alcatel.de>
  3. X-Original-Date: Thu, 1 Feb 96 14:18:32 +0100
  4. Path: in1.uu.net!bounce-back
  5. Date: 01 Feb 96 16:35:02 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Organization: -
  8. In-Reply-To: mlg@scr.siemens.com's message of 31 Jan 1996 20:44:58 GMT
  9. Newsgroups: comp.std.c++
  10. Subject: Re: When can definitions of library functions be provided by a program?
  11. References: <DM2Bv9.C7p@scr.siemens.com>
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMRDt1+EDnX0m9pzZAQHdtAGAizHikd+urmXuE2LQi7gzoX/YN9Mxohj1
  14.     7TfXNn8JxsImYBTmpHPjXcwFKbd+CQ+y
  15.     =ZM/r
  16.  
  17. In article <DM2Bv9.C7p@scr.siemens.com> mlg@scr.siemens.com (Michael
  18. Greenberg) writes:
  19.  
  20. |> I'm trying to figure out under what circumstances a program can supply
  21. |> a definition for a library function.  Is it the case that a program
  22. |> cannot supply a definition for any library function except for those
  23. |> listed in 17.3.3.4 (new & delete with various signatures)?
  24.  
  25. The only library functions that the user can replace are those where
  26. it says explicitly that they can be replaced: operator new, operator
  27. delete, unexpected and terminate.
  28.  
  29.     [ Moderator's note: Michael Greenberg is correct: only new and   ]
  30.     [ delete can be replaced.  The user is not allowed to supply     ]
  31.     [ definitions for unexpected() and terminate(), although a       ]
  32.     [ similar effect can be obtained by calling set_unexpected() and ]
  33.     [ set_terminate().  -fjh.                                        ]
  34.  
  35. |> In other words (typos not withstanding), is
  36.  
  37. |> #include <string.h>
  38.  
  39. |> int std::strlen(const char*) { ... }
  40.  
  41. |> legal?  What if <string.h> is not included?
  42.  
  43. Illegal, with or without string.h.
  44.  
  45. |> (As an aside, what's the 'C' standard have to say about this?)
  46.  
  47. Basically the same thing, except that there are no user replaceable
  48. functions.  The compiler is allowed to know the semantics of all of
  49. the library functions (and the restrictions concerning the semantics
  50. of the replaceable functions), and take advantage of them in its
  51. optimizations.  (The most obvious case: the compiler knows that none
  52. of these functions access any of your global variables, so it may
  53. maintain the global variables in a register accross calls to the
  54. function.  I have already used a C compiler that did this.)
  55.  
  56. --
  57. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  58. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  59. Conseils, itudes et rialisations en logiciel orienti objet --
  60.                 -- A la recherche d'une activiti dans une region francophone
  61. ---
  62. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  63.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  64.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  65.